package vn.co.thn.android.videohot.common;
import com.android.volley.VolleyError;

import vn.co.thn.android.serviceconnect.callback.RequestError;
import vn.co.thn.android.serviceconnect.request.RequestService;
import vn.co.thn.android.videohot.R;
import vn.co.thn.android.videohot.VHApp;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;

public class VHCommonActivity extends FragmentActivity implements OnClickListener ,RequestError{
	private ProgressDialog progressDialog;
	protected RequestService mRequestService=VHApp.getRequestService();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		overridePendingTransition(R.anim.fragment_slide_right_enter, R.anim.fragment_slide_left_exit);
		mRequestService.setRequestError(this);
		progressDialog = new ProgressDialog(this);
		progressDialog.setIndeterminate(true);
		progressDialog.setCancelable(false);
		progressDialog.setMessage("loading...");
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		if(findViewById(R.id.nav_back)!=null)
		findViewById(R.id.nav_back).setOnClickListener(this);
	}
	@Override
	public void onBackPressed() {
		final int backCount = getSupportFragmentManager().getBackStackEntryCount();
        if (backCount == 0) {
            finish();
            overridePendingTransition(R.anim.fragment_slide_left_enter, R.anim.fragment_slide_right_exit);            
        } else {
            super.onBackPressed();
            
        }
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.nav_back:
			finish();
			overridePendingTransition(R.anim.fragment_slide_left_enter, R.anim.fragment_slide_right_exit);
			break;

		default:
			break;
		}
	}
	
	public void setMessageProcess(String TextMessage){
		progressDialog.setMessage(TextMessage);
	}
	@Override
	public void onError(VolleyError error) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onException(Exception e) {
		// TODO Auto-generated method stub
		
	}
	
}
